import Vue from "vue";
import Vuex from "vuex";
Vue.use(Vuex)

// 创建store实例
const store = new Vuex.Store({
    state: {
        routes: []      //存放全局的数组
    },
    mutations: {    //同步方法
        setRoutes (state, routes) {
            state.routes = routes
        }
    },
    actions: {     //异步方法
        setRoutesAsync (context, routes) {
            context.commit('setRoutes', routes)
        }
    },
    getters: {
        getRourtes (state) {
            return state.routes
        }
    }
})

export default store